package com.manli.api.controller;

import java.util.Arrays;
import java.util.Map;
import com.manli.api.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.manli.api.base.annotation.Permissions;
import com.manli.api.pojo.QueryParams;
import com.manli.api.dto.MajorBranchPartner;
import com.manli.api.service.MajorBranchPartnerService;



/**
 * 主店分店主营类别关联
 *
 * @author manli
 * @email 
 * @date 2020-05-15 13:13:01
 */
@Api(value="/majorbranchpartner", tags="主店分店主营类别关联")
@RestController
@RequestMapping("api/majorbranchpartner")
public class MajorBranchPartnerController {
    @Autowired
    private MajorBranchPartnerService majorBranchPartnerService;

    /**
     * 列表
     */
    @ApiOperation(value = "主店分店主营类别关联列表",notes = "get方式，请求参数直接跟url后面，如?page=1&limit=10")
    @PostMapping("/list")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result list(@RequestBody QueryParams params){
        return majorBranchPartnerService.queryPage(params);
    }

    /**
     * 全部数据信息
     */
    @ApiOperation(value = "主店分店主营类别关联全部数据信息",notes = "get方式，查询全部数据")
    @PostMapping("/all")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result all(){
        return majorBranchPartnerService.queryAll();
    }

    /**
     * 单条信息
     */
    @ApiOperation(value = "主店分店主营类别关联单条信息",notes = "主店分店主营类别关联单条信息")
    @GetMapping("/info/{majorBranchPartnerId}")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result info(@PathVariable("majorBranchPartnerId") Integer majorBranchPartnerId){
        return majorBranchPartnerService.getById(majorBranchPartnerId);
    }

    /**
     * 保存
     */
    @ApiOperation(value = "主店分店主营类别关联保存",notes = "主店分店主营类别关联保存")
    @PostMapping("/save")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result save(@RequestBody MajorBranchPartner majorBranchPartner){
        return majorBranchPartnerService.save(majorBranchPartner);
    }

    /**
     * 修改
     */
    @ApiOperation(value = "主店分店主营类别关联修改",notes = "主店分店主营类别关联修改")
    @PostMapping("/update")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result update(@RequestBody MajorBranchPartner majorBranchPartner){
        return majorBranchPartnerService.updateById(majorBranchPartner);
    }

    /**
     * 删除单条数据
     */
    @ApiOperation(value = "主店分店主营类别关联删除",notes = "主店分店主营类别关联删除")
    @ApiImplicitParam(name = "majorBranchPartnerIds", value = "id",dataType = "int", required = true)
    @DeleteMapping("/delete")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result delete(Integer majorBranchPartnerId){
        return majorBranchPartnerService.removeById(majorBranchPartnerId);
    }

    /**
     * 删除多条数据
     */
    @ApiOperation(value = "主店分店主营类别关联删除",notes = "主店分店主营类别关联删除")
    @ApiImplicitParam(name = "majorBranchPartnerIds", value = "id数组,json字符串",dataType = "id数组,json字符串", required = true)
    @DeleteMapping("/deleteIds")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result deleteIds(@RequestBody Integer[] majorBranchPartnerIds){
        return majorBranchPartnerService.removeByIds(Arrays.asList(majorBranchPartnerIds));
    }

}
